<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户管理</title>

<link rel="stylesheet"
	href="assets/bootstrap-table/bootstrap-table.css">
<link rel="stylesheet"
	href="assets/bootstrap-table/bootstrap-editable.css">
<script src="assets/bootstrap-table/jquery.min.js"></script>
<script src="assets/bootstrap-table/bootstrap.min.js"></script>
<script src="assets/bootstrap-table/bootstrap-table.js"></script>
<script src="assets/bootstrap-table/bootstrap-table-export.js"></script>
<script src="assets/bootstrap-table/tableExport.js"></script>
<script src="assets/bootstrap-table/bootstrap-table-editable.js"></script>
<script src="assets/bootstrap-table/bootstrap-editable.js"></script>
<script src="js/bootstrap-table-zh-CN.min.js"></script>

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.min.js"></script>
<![endif]-->
<style>
.ml10 {
	margin-left: 10px;
}

#operate-success {

	font-size: 16px;
	background-color: #8AC007;
	color: #FBFBFB;
	visibility: hidden
}
</style>
</head>
<body>
	<div class="container-fluid">
		<div class="page-header">
			<h1>用户管理&nbsp;&nbsp;</h1>
		</div>
		<div style="text-align: center;">
			<span id="operate-success">设置成功</span>
		</div>
		<div>
			<table id="table" data-toggle="table" data-show-export="false"
				data-url="user/getAllUser.do" data-search="true"
				data-show-refresh="true" data-show-toggle="true"
				data-side-pagination="server" data-pagination="true"
				data-show-columns="true">
				<thead>
					<tr>
						<!-- <th data-field="state" data-checkbox="true"></th> -->
						<th data-field="nickname">昵称</th>
						<th data-field="openId">openId</th>
						<th data-field="imgUrl">头像</th>
						<th data-field="sex" data-formatter="statusSex">性别</th>
						<th data-field="place" data-formatter="statusFormatter" data-sortable="true">系统职务</th>
						<th data-field="action" data-formatter="actionFormatter"
							   data-events="actionEvents">权限修改</th>
					    <th data-field="name">姓名</th>
						<th data-field="headship">实际职务</th>
						<th data-field="email">Email</th>
						<th data-field="phone">手机号</th>
						<th data-field="address">家庭住址</th>
						<th data-field="subScribe">关注</th>
						<th data-field="subscribeTime" data-sortable="true">关注时间</th>												
						<th data-field="country" data-visible="false">国家</th>
						<th data-field="province" data-visible="false">省份</th>
						<th data-field="city" data-visible="false">城市</th>
						<th data-field="groupId" data-visible="false">分组ID</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
	<script>
	var campusId=1;
	
	function statusSex(value, row, index) {
		if (value == "0")
			return "?";
		else if (value == "1") {
			return "男";
		}else if (value == "2") {
			return "女";
		}
	  }
	
   function statusFormatter(value, row, index) {
	if (value == "0")
		return "未认证";
	else if (value == "1")
		return "普通员工";
	else if (value == "2") {
		return "安全人员";
	}else if (value == "3") {
		return "资产管理人员";
	}else if (value == "4") {
		return "财务管理人员";
	}else if (value == "5") {
		return "综合部人员";
	}else if (value == "6") {
		return "领导";
	}
  }

   function actionFormatter(value, row, index) {

			return [
					'<a class="superAdmin ml8 fa fa-user-plus" href="javascript:void(0)" title="设为领导">',
					'&nbsp;&nbsp;',
					'</a>',
					'<a class="colligateAdmin ml8 fa fa-user-plus" href="javascript:void(0)" title="设为综合部人员">',
					'&nbsp;&nbsp;',
					'</a>',
					'<a class="financeAdmin ml8 fa fa-user-circle" href="javascript:void(0)" title="设为财务管理人员">',
					'&nbsp;&nbsp;',
					'</a>',
					'<a class="assetAdmin ml8 fa fa-user-plus" href="javascript:void(0)" title="设为资产管理人员">',
					'&nbsp;&nbsp;',
					'</a>',
					'<a class="admin ml8 fa fa-user" href="javascript:void(0)" title="设为安全人员">',
					'&nbsp;&nbsp;',
					'</a>',
					'<a class="common ml8 fa fa-user-circle" href="javascript:void(0)" title="设置普通员工">',
					'&nbsp;&nbsp;',
					'</a>',
					'<a class="com ml8 fa fa-user-times" href="javascript:void(0)" title="未认证">',
					'&nbsp;&nbsp;',
					'</a>'].join('');

	}
   
   window.actionEvents = {
			'click .superAdmin' : function(e, value, row, index) {
				//alert("admin");
				$.post("../../shambles/user/upAtionFormatter.do", {
					openId : row.openId,
					place:6,
                   campusId:campusId,
				}, function(text) {
					
					if (text == -1 || text == 0) {
						setSuccess("设置为领导失败。");
					} else {
						setSuccess("设置为领导成功。");
						$('#table').bootstrapTable('updateRow', {
							index : index,
							row : {
								type : 2
							}
						});
						$('#table').bootstrapTable('refresh', {silent: true});
					}

				});
			},
			'click .colligateAdmin' : function(e, value, row, index) {
				//alert("admin");
				$.post("../../shambles/user/upAtionFormatter.do", {
					openId : row.openId,
					place:5,
                   campusId:campusId,
				}, function(text) {
					
					if (text == -1 || text == 0) {
						setSuccess("设置为领导失败。");
					} else {
						setSuccess("设置为领导成功。");
						$('#table').bootstrapTable('updateRow', {
							index : index,
							row : {
								type : 2
							}
						});
						$('#table').bootstrapTable('refresh', {silent: true});
					}

				});
			},
			'click .financeAdmin' : function(e, value, row, index) {
				//alert("admin");
				$.post("../../shambles/user/upAtionFormatter.do", {
					openId : row.openId,
					place:4,
                   campusId:campusId,
				}, function(text) {
					
					if (text == -1 || text == 0) {
						setSuccess("设置为财务管理人员失败。");
					} else {
						setSuccess("设置为财务管理人员成功。");
						$('#table').bootstrapTable('updateRow', {
							index : index,
							row : {
								type : 2
							}
						});
						$('#table').bootstrapTable('refresh', {silent: true});
					}

				});
			},
			'click .assetAdmin' : function(e, value, row, index) {
				//alert("admin");
				$.post("../../shambles/user/upAtionFormatter.do", {
					openId : row.openId,
					place:3,
                   campusId:campusId,
				}, function(text) {
					
					if (text == -1 || text == 0) {
						setSuccess("设置为资产管理人员失败。");
					} else {
						setSuccess("设置为资产管理人员成功。");
						$('#table').bootstrapTable('updateRow', {
							index : index,
							row : {
								type : 2
							}
						});
						$('#table').bootstrapTable('refresh', {silent: true});
					}

				});
			},
			'click .admin' : function(e, value, row, index) {
				//alert("common");
				$.post("../../shambles/user/upAtionFormatter.do", {
					openId : row.openId,
					place:2,
					campusId:campusId,
				}, function(text) {
					if (text == -1 || text == 0) {
						setSuccess("设置为安全人员失败。");
					} else {
						setSuccess("设置为安全人员成功。");
						$('#table').bootstrapTable('updateRow', {
							index : index,
							row : {
								type : 1
							}
						});
						$('#table').bootstrapTable('refresh', {silent: true});
					}

				});
			},
			'click .common' : function(e, value, row, index) {
				//alert("superAdmin");
				$.post("../../shambles/user/upAtionFormatter.do", {
					openId : row.openId,
					place:1,
					campusId:campusId,
				}, function(text) {
					if (text == -1 || text == 0) {
						setSuccess("设置为普通员工失败。");
					} else {
						setSuccess("设置为普通员工成功。");
						$('#table').bootstrapTable('updateRow', {
							index : index,
							row : {
								type : 0
							}
						});
						$('#table').bootstrapTable('refresh', {silent: true});
					}

				});
			},
			'click .com' : function(e, value, row, index) {
				//alert("common");
				$.post("../../shambles/user/upAtionFormatter.do", {
					openId : row.openId,
					place:0,
					campusId:campusId,
				}, function(text) {
					if (text == -1 || text == 0) {
						setSuccess("设置为未认证人员失败。");
					} else {
						setSuccess("设置为未认证人员成功。");
						$('#table').bootstrapTable('updateRow', {
							index : index,
							row : {
								type : 1
							}
						});
						$('#table').bootstrapTable('refresh', {silent: true});
					}

				});
			}
		};
	</script>
</body>
</html>